{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "import time\n",
    "searchPath=os.path.abspath('..')\n",
    "sys.path.append(searchPath)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.datasets import load_iris\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from knn.knn_base import KNN\n",
    "from knn.knn_kdtree import KNNKdTree\n",
    "from utils.data_generater import random_points\n",
    "from utils.plot import plot_knn_predict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getData(number):\n",
    "    data = random_points(2, number)\n",
    "    label = [0] * (number // 2) + [1] * (number // 2)\n",
    "    return np.array(data), np.array(label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataList = []\n",
    "labelList = []\n",
    "for num in [30, 500, 1000, 2000, 5000, 10000, 50000, 400000]:\n",
    "    data, label = getData(num)\n",
    "    dataList.append(data)\n",
    "    labelList.append(label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "models = {\"knn\":KNN(), \"kdtree\":KNNKdTree()}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "model = knn, dataNum = 30, takeTime = 0.00391\n",
      "model = kdtree, dataNum = 30, takeTime = 0.00417\n",
      "model = knn, dataNum = 500, takeTime = 0.03806\n",
      "model = kdtree, dataNum = 500, takeTime = 0.00856\n",
      "model = knn, dataNum = 1000, takeTime = 0.05203\n",
      "model = kdtree, dataNum = 1000, takeTime = 0.01386\n",
      "model = knn, dataNum = 2000, takeTime = 0.1387\n",
      "model = kdtree, dataNum = 2000, takeTime = 0.02863\n",
      "model = knn, dataNum = 5000, takeTime = 0.28177\n",
      "model = kdtree, dataNum = 5000, takeTime = 0.07277\n",
      "model = knn, dataNum = 10000, takeTime = 0.47404\n",
      "model = kdtree, dataNum = 10000, takeTime = 0.16433\n",
      "model = knn, dataNum = 50000, takeTime = 2.0887\n",
      "model = kdtree, dataNum = 50000, takeTime = 0.93545\n",
      "model = knn, dataNum = 400000, takeTime = 16.82156\n",
      "model = kdtree, dataNum = 400000, takeTime = 11.85994\n"
     ]
    }
   ],
   "source": [
    "for data, label in zip(dataList, labelList):\n",
    "    for name, model in models.items():\n",
    "        startTime = time.time()\n",
    "        model.fit(data, label)\n",
    "        for i in range(5):\n",
    "            model.predict([0.3, 0.2])\n",
    "        print(\"model = %s, dataNum = %s, takeTime = %s\"%(name, len(data), round(time.time() - startTime, 5)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<knn.knn_kdtree.Node object at 0x1091d00b8>\n",
      "<knn.knn_kdtree.Node object at 0x1091d0240>\n",
      "<knn.knn_kdtree.Node object at 0x1091d0080>\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmUXFW5/vHvW9Vd1VMSMiFkItGEMTJoMyuESYJCAhIkQbgy5ncZxAtcEJlEcEAQvVwFIYKCCkRARpn0AoIgEYIMAgkaAmSCJCQhQ3fX/P7+qCb2UJ2uJFV1qqqfz1q90lX79Dlvzup++vQ+++xt7o6IiFSXUNAFiIhI4SncRUSqkMJdRKQKKdxFRKqQwl1EpAop3EVEqpDCXUS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/vLWWTn3K9m+XyfAFwJXA3ESllcAPI5H6cB17v7KgB3X1biGkstn3PiQP/2zwfQfZ2KilZu4R74kn5lKJ9z0tEpwKNFrSh4vZ4TM9sNGOnufyhlYQHJ53tkW2BbM3vOzGaZ2cSSVReMfM7J5cDxZraI7Ky3Xy9NaaWR15S/JVSwJf2qSN7/XzM7HmgGirMoY/nY4Dmx7KK6PwFOLFVBAcvne6SGbNfMBLJ/2f3FzMa7+0dFri0o+ZyTacCt7n6tme1Ndk2K8e6ee8HTClNuV+4bs6QfG1rSr4rkc04ws4OBi4FJ7h4vUW1B6e2c9APGA382s3eBvYAHq/imar4/Nw+4e9Ld3wHeIhv21Sqfc3IKcBeAuz8P1JGdd6YqlFu4r1/Sz8wiZG+YPthlm4+X9IO+saRfr+ekvQviJrLBXu19qdDLOXH31e4+xN1Hu/tosvchJrn77GDKLbp8fm7uJ3vjHTMbQrabZn5JqyytfM7JAuAgADPbgWy4Ly9plUVUVuHe3of+8ZJ+c4C7vH1JPzOb1L7ZLcDg9iX9zgV6HAZXDfI8J9cATcDdZvaKmXX9Jq4qeZ6TPiPP8/E4sMLM3gSeAs539xXBVFx8eZ6T84DTzOxV4E7gxGq6UNQTqiIiVaisrtxFRKQwFO4iIlVI4S4iUoUU7iIiVUjhLiJShRTuIiJVSOEuIlKFFO4iIlXo/wN7Vchil0gbWwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1091d0fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "point = (0.3, 0.2)\n",
    "model = KNNKdTree()\n",
    "model.fit(dataList[0], labelList[0])\n",
    "plot_knn_predict(model, dataList[0], labelList[0], point)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
